/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-11-27 02:38:44
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.bp.service;

import java.util.List;

import com.joysuch.wwyt.bp.bean.BpDeviceFacilityListBean;
import com.joysuch.wwyt.bp.bean.BpDeviceFacilityListSearchBean;
import com.joysuch.wwyt.bp.entity.BpDeviceFacilityCollection;
import com.joysuch.wwyt.bp.enums.DeviceFacilityTypes;
import com.joysuch.wwyt.mh.bean.MhMonitoringPointBean;
import com.joysuch.wwyt.mh.entity.MhMonitoringPoint;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface BpDeviceFacilityCollectionService {

    public void add(BpDeviceFacilityCollection entity) throws Exception;

    void update(BpDeviceFacilityCollection entity) throws Exception;

    Page<BpDeviceFacilityCollection> findByPage(Pageable page);

    List<BpDeviceFacilityCollection> findAll();

    void delteByDeviceTypeAndDeviceId(DeviceFacilityTypes type, Long id);

    void delete(Long id);

    BpDeviceFacilityCollection findById(Long id);

    /**
     * 分页，搜索
     *
     * @param page
     * @param condition
     * @return
     */
    public Page<BpDeviceFacilityListBean> findByPage(Pageable page, BpDeviceFacilityListSearchBean condition);

    public BpDeviceFacilityCollection addOrUpdateProductionFacility(Long deviceId, String code, String name,
                                                                    String subType, Long districtId, Long majorHazardId, String coordinates, String keyEquipment);

    public BpDeviceFacilityCollection addOrUpdateOtherDevice(DeviceFacilityTypes type, Long deviceId, String code,
                                                             String name, Long districtId, Long majorHazardId, String coordinates);

    /**
     * 通用添加方法，包含了所有的元素
     *
     * @param type
     * @param deviceId
     * @param code
     * @param name
     * @param subType
     * @param districtId
     * @param majorHazardId
     * @param coordinates
     * @param keyEquipment
     */
    public BpDeviceFacilityCollection addOrUpdateDevice(DeviceFacilityTypes type, Long deviceId, String code,
                                                        String name, String subType, Long districtId, Long majorHazardId, String coordinates, String keyEquipment);

    public void bindDeviceAndMonitorPoints(BpDeviceFacilityCollection device, List<MhMonitoringPoint> points);

    public void bindDeviceAndMonitorPointsByIds(BpDeviceFacilityCollection device, List<Long> pointIds);

    public void bindDeviceAndMonitorPointss(BpDeviceFacilityCollection device, List<MhMonitoringPointBean> pointIds);

    /**
     * 查询监测点绑定的设备
     *
     * @param monitorPointId 监测点ID
     * @return
     */
    BpDeviceFacilityCollection findMonitoryPointBindedDevice(Long monitorPointId);

    public void bindMonitorPoint(DeviceFacilityTypes type, Long id, Long monitorPointId);

    public void unbindMonitorPoint(DeviceFacilityTypes type, Long id, Long monitorPointId);

    /**
     * 查询指定类型的设备绑定的监测点编号列表
     *
     * @param type 设备类型
     * @param id   相关设备ID
     * @return 绑定的监测点编码列表。没有关联监测点，返回空列表
     */
    List<String> findDeviceBindedMonitorPointCodes(DeviceFacilityTypes type, Long id);

    /**
     * 批量查询设备关联的监测点列表，确保返回的List和ids是一一对应，如果id对应没有监测点，返回空列表
     *
     * @param type 设备类型
     * @param ids  设备ID列表
     * @return
     */
    List<List<String>> findDeviceBindedMonitorPointCodes(DeviceFacilityTypes type, List<Long> ids);

}
